<?php
/**
 * Created by PhpStorm.
 * User: cgp
 * Date: 14-8-23
 * Time: 下午4:34
 */
define('ROOT_PATH','/var/www/html/new/');
//校验
$token = $_GET['token'];
$domain = $_SERVER['HTTP_HOST'];
$tokens = include 'config.php';
if (!isset($tokens[$domain]) || $token != $tokens[$domain]) {
    exit('Access Denied!');
}

$pid = $_GET['pid'];
if (!$pid || !is_numeric($pid)) {
    exit('Empty pid');
}
$fileName =   dirname(__FILE__) . "LinkProducts.inc.php";
$products = include $fileName;
if (!isset($products[$pid])) {
    exit("Product Not Exist! pid={$pid}");
}
//TODO:how to get price?
//print_r($products);
echo json_encode( $products[$pid] );